package com.travel.travelServer.utils;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

@Data
public class BaseEntity<T extends BaseEntity<?>> extends Model<T> implements Serializable {

    @TableId(type = IdType.ASSIGN_ID)
    @JsonFormat(shape=JsonFormat.Shape.STRING)
    private Long id;

    private Boolean whetherDelete;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "created_time",fill = FieldFill.INSERT)
    private Date createdTime;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "updated_time",fill = FieldFill.INSERT)
    private Date updatedTime;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }
}
